<?php
/*
 * File Name : FundRaisingGoals.php
 * Description : Validate the agency id and set the fund raising goals.
 * Created By : Pratibha Awasthi
 */

include_once "basePage.php";

class FundRaisingGoals extends basePage{
	
	// Sets the new Fund Raising Goals for the Subscriber 
	public function setfundraisinggoals(){
		
			$agencyid = $_POST['agencyid'];
			
			session_start();
			$_SESSION['agencyid'] = $agencyid;
			
			if($agencyid == NULL){
				echo "<h3> Please enter the Agency Id !!! <h3>";
				echo "<input type = 'submit' name = 'submit' value = 'Back' onclick= 'history.go(-1);'>";
			}
			else{
				
				$con = mysql_connect('localhost','pa_user','secret_password');
				if (!$con){
			  		die('Could not connect: ' . mysql_error());
			  	}
			  
				mysql_select_db("TGS_GM_RESERVATION", $con);
				
				$result = mysql_query("SELECT Name FROM TGS_GM_RESERVATION.tblagency where ID = '{$agencyid}'");
				$row =  mysql_fetch_array($result);
				
				$resultfrequency = mysql_query("SELECT * FROM TGS_GM_RESERVATION.lkpfrequency");
				
				// Check id the validation for the Agency Id passes or fails
				if($row['Name'] == NULL){
					
					echo "<h3> Invalid Agency ID !!! <br/> Please enter a valid Agency ID. <h3>";
					echo "<input type = 'submit' name = 'submit' value = 'Back' onclick= 'history.go(-1);'>";
				}
				else{
					
					echo <<<EPRINT
					<h2> Agency Name - {$row['Name']} </h2>
					<h3> Set Fund Raising Goals </h3>
					<form name = "fund" method ="post" action = "InsertFunds">
					<table class= "fundraising">
					<tr> <td> Fund name </td> <td> <input name="fundname" type="text" id="fundname"> </td> </tr>
						<tr> <td> Frequency </td> <td>
EPRINT;
					    echo '<select name="frequency">';
				    	echo '<option value="0">Choose Frequency of Payment</option>';
				    	while($row = mysql_fetch_array($resultfrequency)){
							echo <<<ESEARCHCITY
				    		<option> {$row['FrequencyType']} </option>                      
ESEARCHCITY;
        				}
						echo '</select>';
					echo <<<EPRINT
						</td> </tr>
						
						<tr> <td> StartDate </td> <td> <input name="startdate" type="text" id="startdate"> (mm/dd/yyyy)</td> </tr>
						<tr> <td> EndDate </td> <td> <input name="enddate" type="text" id="enddate"> (mm/dd/yyyy)</td> </tr>
						<tr> <td> Amount </td> <td> <input name="amount" type="text" id="amount"> $</td> </tr>
					</table>
					
					<p><br/><br/><input type = 'submit' name = 'submit' value = 'Set Goals'></p>
					
					</form>
					<br/><input type = 'submit' name = 'submit' value = 'Back' onclick= 'history.go(-1)' >
EPRINT;
					//echo "<p><input type = 'submit' name = 'submit' value = 'Back' onclick= 'history.go(-1)' ></p>";
				}
			
			}
	}

}

$page = new FundRaisingGoals();
$page->header();
$page->top_menu_agency();
$page->setfundraisinggoals();
$page->footer();

?>